<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Spatie\Activitylog\Models\Activity;

/**
 * @mixin Activity
 */
class ActivityAdminLogResource extends JsonResource
{
    public static $wrap = null;

    /**
     * Transform the resource into an array.
     *
     * @param  Request              $request
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'username' => $this->causer->username ?? '未知用户',
            'mobile' => $this->causer->mobile ?? '',
            'event' => $this->event,
            'event_name' => $this->event_name,
            'user_role' => '管理员',
            'subject_id' => $this->subject_id,
            'description' => $this->description,
            'updated_at' => $this->updated_at->toDateTimeString(),
        ];
    }
}
